<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/24
  Time: 16:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<button id="queryByPage">分页查询</button>
<table border="1" width="500" cellspacing="0">
    <caption>学生管理</caption>
    <thead>
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>地址</th>
    </tr>
    </thead>
    <tbody></tbody>
</table>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.0.0.min.js"></script>
<script>
    $(function () {
        //第一次调用
        queryByPage(1);
    })
    function queryByPage(page) {
        $.get("queryByPage", {page: page}, function (result) {
            let data = result.data.list;
            console.log(result)
            let str = ``;
            $.each(data,function (index,data) {
                str += `<tr>
                        <td>\${data.id}</td>
                        <td>\${data.name}</td>
                        <td>\${data.address}</td>
                        </tr>`
            })
            //html片段填充
            $("tbody").html(str)
        });
    }

    // function queryByPage(page) {
    //     $.get("findTwo",function (result) {
    //         console.log(result);
    //         let data = result.data;
    //         let str =``;
    //         $.each(data,function (index,data) {
    //             str += `<tr>
    //                     <td>\${data.id}</td>
    //                     <td>\${data.name}</td>
    //                     <td>\${data.address}</td>
    //                     </tr>`
    //         })
    //         $("tbody").html(str)
    //     })
    // }
</script>
</body>
</html>
